# 1 "C:/Bruker/TopSpin3.2_PL6/exp/stan/nmr/lists/pp/user/cpmat.cmw"
;mat.ajp (TopSpin 3.0)

; MAT CS-CSA experiment 
; see Levitt et al.

;Avance III version
;parameters:
;d1 : recycle delay
;p11 : SHAP
;pl1 : power for 13C CP
;pl22 : power for 13C PI pulses (i.e., P2)
;sp11 : power for SHAPs
;spnam11 : file name for SHAP
;in0 : (no of rotor periods) * (rotor period) / number of increments, for calibration only
;inf1: = in0, for calibration only
;cnst31 : MAS spin rate (Hz)
;cnst1 : =1/6, 7/6, 13/6, ...
;cnst2 : =1/6, 7/6, 13/6, ...
;cnst3 : =1/6, 7/6, 13/6, ...
;cnst4 : =1/6, 7/6, 13/6, ...
;cnst5 : =1/6, 7/6, 13/6, ...
;cnst6 : =1/6, 7/6, 13/6, ...
;d31 : rotor period
;d21 : 1st MAT delay for echo only
;d22 : 2nd MAT delay
;d23 : 3rd MAT delay
;d24 : 4th MAT delay
;d25 : 5th MAT delay
;d26 : 6th MAT delay for echo only
;d27 : 1st MAT delay for anti-echo only (equiv to d21)
;d28 : 6th MAT delay for anti-echo only(equiv to d26)
;in21 : =d31/(td1*6), increment of 1st delay (echo)
;in22 : =d31/(td1*6), decrement of 2nd delay
;in23 : =d31/(td1*6), increment of 3rd delay
;in24 : =d31/(td1*6), decrement of 4th delay
;in25 : =d31/(td1*6), increment of 5th delay
;in26 : =d31/(td1*6), decrement of 6th delay (echo)
;in27 : =d31/(td1*6), increment of 1st delay (anti-echo)
;in28 : =d31/(td1*6), decrement of 6th delay (anti-echo)
;FnMode : echo-antiecho
;MC2 : echo-antiecho
;NS : 32 * n
;Note order of delays is reversed in anti-echo experiment relative to echo experiment
# 45 "C:/Bruker/TopSpin3.2_PL6/exp/stan/nmr/lists/pp/user/cpmat.cmw"
;$COMMENT=PASS CS-CSA experiment, continuous or discontinuous variation of delays
;$CLASS=Solids
;$DIM=2D
;$TYPE=cross polarisation
;$SUBTYPE=shift/CSA correlation
;$OWNER=Bruker
"d31=1s/cnst31"
;"p2=p1*2"
;"d21=d31*cnst1-p2/2"	
;"d22=d31*cnst2-p2"	
;"d23=d31*cnst3-p2"	
;"d24=d31*cnst4-p2"	
;"d25=d31*cnst5-p2"	
;"d26=d31*cnst6-p2/2"
"d21=d31*cnst1-p2/2-1u"	
"d22=d31*cnst2-p2"	
"d23=d31*cnst3-p2"	
"d24=d31*cnst4-p2"	
"d25=d31*cnst5-p2"	
"d26=d31*cnst6-p2/2-de"
"d27=d31*cnst1-p2/2-de"
"d28=d31*cnst6-p2/2-1u"


"d30=d31-de"
# 71 "C:/Bruker/TopSpin3.2_PL6/exp/stan/nmr/lists/pp/user/cpmat.cmw"
define loopcounter count
"count=td1/2"

"in0=d31*(cnst1+cnst2+cnst3+cnst4+cnst5+cnst6)/count"
;"in0=inf1"
"in21=d31*cnst1/count"
"in22=d31*cnst2/count"
"in23=d31*cnst3/count"
"in24=d31*cnst4/count"
"in25=d31*cnst5/count"
"in26=d31*cnst6/count"
"in27=d31*cnst1/count"
"in28=d31*cnst6/count"
;cnst11 : to adjust t=0 for acquisition, if digmod = baseopt
"acqt0=1u*cnst11"
;"p2=p1*2"

define delay CT
"CT=d31*(cnst1+cnst2+cnst3+cnst4+cnst5+cnst6)"
# 91 "C:/Bruker/TopSpin3.2_PL6/exp/stan/nmr/lists/pp/user/cpmat.cmw"
	
# 1 "C:/Bruker/TopSpin3.2_PL6/exp/stan/nmr/lists/pp/Avancesolids.incl" 1
;Avancesolids.incl
;   for TCU3
;
;version 1 28.2.2001, written by HF
;	   4.4.2006, complemented by Ste

;$CLASS=Solids INCL
;$COMMENT=definitions for setrtp and setnmr

;switch between 1H or 19F output (H amplifier) 
# 14 "C:/Bruker/TopSpin3.2_PL6/exp/stan/nmr/lists/pp/Avancesolids.incl"
;gating pulse for RX, ADC and HPPR auto mode


# 18 "C:/Bruker/TopSpin3.2_PL6/exp/stan/nmr/lists/pp/Avancesolids.incl"
;explicit blanking of preamp, receiver, adc, not implemented yet


# 26 "C:/Bruker/TopSpin3.2_PL6/exp/stan/nmr/lists/pp/Avancesolids.incl"
;generate dwell clock


;turn dwell clock on/off
# 32 "C:/Bruker/TopSpin3.2_PL6/exp/stan/nmr/lists/pp/Avancesolids.incl"
;


# 36 "C:/Bruker/TopSpin3.2_PL6/exp/stan/nmr/lists/pp/Avancesolids.incl"
;define data sampling for WAHUHA type experiments, samples analogue or digitally for d9, closes receiver


# 40 "C:/Bruker/TopSpin3.2_PL6/exp/stan/nmr/lists/pp/Avancesolids.incl"
;explicit transmitter blanking, not supported yet

;NCO switching, to be implemented

;$id: $
# 92 "C:/Bruker/TopSpin3.2_PL6/exp/stan/nmr/lists/pp/user/cpmat.cmw" 2
# 1 "C:/Bruker/TopSpin3.2_PL6/exp/stan/nmr/lists/pp/rot_prot.incl" 1
;rot_prot.incl
;avance-version (13/01/29)
;Test the rf on-time and duty cycle
;protect against misset cnst31, rotation speed below 1000 Hz
;
;$CLASS=Solids INCL
;$COMMENT=protect against misset cnst31, rotation speed below 1000 Hz


1m
if "d31 < 1m" goto Passrot
2u
print "rotation period too long, cnst31 misset to less than 1000 Hz!"
goto HaltAcqu
Passrot, 1m
# 19 "C:/Bruker/TopSpin3.2_PL6/exp/stan/nmr/lists/pp/rot_prot.incl"
;$Id: rot_prot.incl,v 1.2.18.4 2013/01/29 15:40:51 ber Exp $
# 94 "C:/Bruker/TopSpin3.2_PL6/exp/stan/nmr/lists/pp/user/cpmat.cmw" 2

			;make sure cnst31 is set >1000
# 1 "mc_line 96 file C:/Bruker/TopSpin3.2_PL6/exp/stan/nmr/lists/pp/user/cpmat.cmw dc-measurement inserted automatically"

    dccorr
# 96 "C:/Bruker/TopSpin3.2_PL6/exp/stan/nmr/lists/pp/user/cpmat.cmw"
  ze
  
1 1m do:f2
  CT
  d1
  d31

  (p3 pl2 ph1):f2
  (p15 pl1 ph2):f1 (p15:sp0 ph10):f2
  1u cpds2:f2 
  d21
  (p2 pl22 ph11):f1			
  d22
  (p2 pl22 ph12):f1			
  d23
  (p2 pl22 ph13):f1			
  d24
  (p2 pl22 ph14):f1			
  d25
  (p2 pl22 ph15):f1			
  d26
# 118 "C:/Bruker/TopSpin3.2_PL6/exp/stan/nmr/lists/pp/user/cpmat.cmw"
  go=1 ph31 ph30:r
  1m wr #0 if #0 zd


2 1m do:f2
  d1
  d31
# 126 "C:/Bruker/TopSpin3.2_PL6/exp/stan/nmr/lists/pp/user/cpmat.cmw"
  (p3 pl2 ph1):f2
  (p15 pl1 ph2):f1 (p15:sp0 ph10):f2
  1u cpds2:f2 
  d28
  (p2 pl22 ph11):f1			
  d25
  (p2 pl22 ph12):f1			
  d24
  (p2 pl22 ph13):f1			
  d23
  (p2 pl22 ph14):f1			
  d22
  (p2 pl22 ph15):f1			
  d27

  go=2 ph31 ph30:r
  1m do:f2
  1m wr #0 if #0 zd

  ;10m mc #0 to 1 F1QF(id21&dd22&id23&dd24&id25&id26) 
  3u id21
  3u dd22
  3u id23
  3u dd24
  3u id25
  3u dd26
  3u id27
  3u dd28
  lo to 1 times count
HaltAcqu, 1m
exit
# 158 "C:/Bruker/TopSpin3.2_PL6/exp/stan/nmr/lists/pp/user/cpmat.cmw"
ph1= {1}*14 {3}*14
ph2= 0
ph10=0


;ph10= 0 1 2 3
;ph11= {0}*4 {1}*4 {2}*4 {3}*4
;ph12= {0}*16 {1}*16 {2}*16 {3}*16
;ph13= {0}*64 {1}*64 {2}*64 {3}*64
;ph14= {0}*256 {1}*256 {2}*256 {3}*256
;ph15= {0}*1024 {1}*1024 {2}*1024 {3}*1024
;ph31= ph10*2+ph11*2+ph12*2+ph13*2+ph14*2+ph15*2
# 172 "C:/Bruker/TopSpin3.2_PL6/exp/stan/nmr/lists/pp/user/cpmat.cmw"
ph11= (14) 0 1 2 3 4 5 6 7 8 9 10 11 12 13
ph12= 0
ph13= (14) 0 1 2 3 4 5 6 7 8 9 10 11 12 13
ph14= 0
ph15= (14) 0 1 2 3 4 5 6 7 8 9 10 11 12 13
ph30= (14) 0 6 12 4 10 2 8 
ph31= {0}*14 {2}*14


